package edu.sdjzu.exam.mapper.group;


import edu.sdjzu.exam.domain.group.UserGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserGroupMapper {

    @Insert("INSERT INTO User_groups (group_name) VALUES (#{groupName})")
    @Options(useGeneratedKeys = true, keyProperty = "groupId")
    void insertUserGroup(UserGroup userGroup);

    @Select("SELECT * FROM User_groups WHERE group_id = #{groupId}")
    UserGroup selectUserGroupById(Long groupId);

    @Update("UPDATE User_groups SET group_name = #{groupName} WHERE group_id = #{groupId}")
    void updateUserGroup(UserGroup userGroup);

    @Delete("DELETE FROM User_groups WHERE group_id = #{groupId}")
    void deleteUserGroup(Long groupId);

    @Select("SELECT * FROM User_groups")
    List<UserGroup> selectAllUserGroups();
}